import React, { Component } from 'react'

export default class App extends Component {
  myRef = React.createRef();
  render() {
    return (
      <div>
        {/* 使用ref 获取input输入的值*/}
        <input ref={this.myRef} />
        <button onClick={() => {
          console.log("click", this.myRef.current.value)
        }}>添加</button>
        <button onClick={this.handleClick2}>添加2</button>
      </div>
    )
  }

  handleClick2 = () => {
    console.log("click", this.myRef.current.value)
  }
}

